#include "../tcp_server_v2.hpp"
#include "http.hpp"
#include <string>

int main() {
    Socket sock;
    sock.create_client("127.0.0.1", 8080);
    string req = "PUT /hello.txt HTTP/1.1\r\nConnection: keep-alive\r\n";
    string context;
    Ultil::read_file("./bigfile", &context);
    req += "Content-Length: " + to_string(context.length()) + "\r\n\r\n";
    cout << "req = " << req << " context.size() = " << context.length() << endl;
    sock.send(req.c_str(), req.size());
    sock.send(context.c_str(), context.size());
    char buf[1024];
    ssize_t n = sock.recv(buf, sizeof(buf));
    if(n < 0) {
        return -1;
    }
    cout << buf << endl;
    sleep(5);
    return 0;
}